﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Diagnostics;
using System.Data;
using System.Collections;
using PBDesk.DAL;

namespace PBDesk.Business.FeedProvider
{
    public class DBMapper
    {
        internal static IEnumerable<System.ServiceModel.Syndication.SyndicationItem> GetFeedsNewsItems(int channelId)
        {
            throw new NotImplementedException();
        }

        internal static void GetFeedsChannelData(int channelId, out string title, out string desc, out string link, out string imageUrl)
        {
            throw new NotImplementedException();
        }

        internal static Dictionary<int, string> GetChannelList()
        {
            Trace.WriteLine("PBDesk.Business.FeedProvider.DBMapper.GetChannelList() Method call start ");
            Dictionary<int, string> list = new Dictionary<int, string>();
            string spName = "PBDsk_GetChannelList";
            string email = string.Empty;
            IDataReader reader = null;
            try
            {
                Hashtable parameters = new Hashtable();
                reader = DBManager.ExecuteDataReader(spName, parameters);
                if (reader != null)
                {
                    while (reader.Read())
                    {
                        int channeId = (int)DBHelper.GetValueFromDataReader<int>(reader, "ChannelID");
                        string title = (string)DBHelper.GetValueFromDataReader<string>(reader, "Title");
                        list.Add(channeId, title);
                    }
                }
            }
            catch (Exception ex)
            {
                throw new Exception("Error while getting DataReader for " + spName, ex);
            }
            finally
            {
                if (reader != null)
                    reader.Close();
            }

            


            return list;
        }
    }
}
